Object.prototype.myCreate = function (obj) {
    function Fn() {}
    Fn.prototype = obj; // 注意
    return new Fn()
}

function myNew(fn,...args) {
    let newFn = Object.create(fn.property);
    let result = fn.call(newFn,...args);
    return result instanceof Object ? newFn : result
}

function myInstace(obj, Obj) {
    let objPro = obj.property;
    let ObjPro = Obj.property;
    while(true){ // 注意// 注意
        if(objPro== null){
            return false
        }
        if(objPro === ObjPro){
            return true
        }
        objPro = objPro.property
    }
}


function depClone(obj) {
    let newObj = obj.constructor == Array ? [] : {}
    Object.values(obj).forEach(key => {
        if (Object.hasOwnProperty(key)) {
            if (typeof obj[key] == "object") {
                newObj[key] = depClone(obj[key])
            } else {
                newObj[key] = obj[key]
            }
        }
    })
    return newObj
}

function clone(obj) {
    let newObj = obj.constructor == Array ? [] : {}
    Object.values(obj).forEach(key => {
        if (Object.hasOwnProperty(key)) {
            obj[key] = obj[key]
        }
    })
    return obj
}


function calculator(object) {
    const objectType = typeof object;
    switch (objectType) {
        case "string": {
            return object.length
        }
        case "boolean": {
            return 4;
        }
        case "number": {
            return 8;
        }
        case "object": {
            if (Array.isArray(object)) {
                return object.map(calculator).reduce((acc, curr) => {
                    return acc + curr
                }, 0)
            } else {
                return sizeOfObject(object)
            }
        }
    }
}

const seen = new WeakSet()

function sizeOfObject(object) {
    if (object == null) {
        return 0;
    }
    let bytes = 0;
    const properties = Object.keys(object)
    for (let i = 0; i < properties.length; i++) {
        const key = properties[i];
        if (typeof object[key] == "object" && object[key] != null) {
            if (seen.has(object[key])) {
                continue
            }
            seen.add(object[key])
        }
        bytes += calculator(key)
        bytes += calculator(object[key])
    }
    return bytes;
}

const testData = {
    a: 11,
    b: "ccc",
    222: false
}

console.log(calculator(testData))